package com.wanmait.wisdom.manage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.wisdom.entity.Rapair;
import com.wanmait.wisdom.manage.service.ManageRapairService;
import com.wanmait.wisdom.mapper.RapairMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class ManageRapairServiceImpl extends ServiceImpl<RapairMapper,Rapair> implements ManageRapairService {

    @Resource
    private RapairMapper rapairMapper;

    @Override
    public Long getRapairFinishedCount() {
        return rapairMapper.selectFinishedCount();
    }

    @Override
    public Long getRapairUnFinishedCount() {
        return rapairMapper.selectUnFinishedCount();
    }

    @Override
    public PageInfo<Rapair> searchRapairByCondition(Rapair rapair, Integer pageNum, Date startTime, Date endTime, Integer pageSize) {
        System.out.println(rapair);
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfo<>(rapairMapper.searchRapairByCondition(rapair,startTime,endTime));
    }

    @Override
    public Rapair selectRapairById(Integer id) {
        return rapairMapper.selectByID(id);
    }

    @Override
    public int updateRapair(Rapair rapair) {
        return rapairMapper.updateByPrimaryKey(rapair);
    }
}
